<html>
<head><meta charset="utf-8"><title>Build script not seeing the target&#x27;s target-features · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Build.20script.20not.20seeing.20the.20target&#x27;s.20target-features.html">Build script not seeing the target&#x27;s target-features</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="205696995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Build%20script%20not%20seeing%20the%20target%27s%20target-features/near/205696995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Fabian von der Warth <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Build.20script.20not.20seeing.20the.20target&#x27;s.20target-features.html#205696995">(Aug 01 2020 at 20:28)</a>:</h4>
<p>Hi, can someone help me figure out how I can make the build script identify the target's target-features? For reference, I made an issue on the repository <a href="https://github.com/rust-lang/rust/issues/75018">https://github.com/rust-lang/rust/issues/75018</a> with a minimal example of what my problem is.</p>



<a name="205697940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Build%20script%20not%20seeing%20the%20target%27s%20target-features/near/205697940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Build.20script.20not.20seeing.20the.20target&#x27;s.20target-features.html#205697940">(Aug 01 2020 at 20:56)</a>:</h4>
<p>Pass your <code>-C target-cpu</code> flag with <code>RUSTFLAGS</code>, not <code>cargo rustc</code>.   The flags passed to <code>cargo rustc</code> are only passed to the final compiler invocation, nothing else.</p>



<a name="205698011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Build%20script%20not%20seeing%20the%20target%27s%20target-features/near/205698011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Build.20script.20not.20seeing.20the.20target&#x27;s.20target-features.html#205698011">(Aug 01 2020 at 20:59)</a>:</h4>
<p>When using <code>--target</code>, <code>RUSTFLAGS</code> is not used when compiling build scripts or other crates for the host.</p>



<a name="205699421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Build%20script%20not%20seeing%20the%20target%27s%20target-features/near/205699421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Fabian von der Warth <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Build.20script.20not.20seeing.20the.20target&#x27;s.20target-features.html#205699421">(Aug 01 2020 at 21:42)</a>:</h4>
<p>Passing -C target-cpu with RUSTFLAGS does not work either, due to the reasons bjorn3 has explained. Doesn't this seem like a cargo bug? It is very weird I can't get this to work.</p>



<a name="205699591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Build%20script%20not%20seeing%20the%20target%27s%20target-features/near/205699591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Fabian von der Warth <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Build.20script.20not.20seeing.20the.20target&#x27;s.20target-features.html#205699591">(Aug 01 2020 at 21:48)</a>:</h4>
<p>Actually, nevermind! After a cargo clean it seems to have bmi2 set in <code>CARGO_CFG_TARGET_FEATURE</code>.  Let me just confirm this on my real project instead of the minimal one.</p>



<a name="205699985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Build%20script%20not%20seeing%20the%20target%27s%20target-features/near/205699985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Fabian von der Warth <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Build.20script.20not.20seeing.20the.20target&#x27;s.20target-features.html#205699985">(Aug 01 2020 at 22:01)</a>:</h4>
<p>Okay, it works now after all with a cargo clean and reading the env variable. Thanks for resolving this!</p>



<a name="205701967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Build%20script%20not%20seeing%20the%20target%27s%20target-features/near/205701967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Build.20script.20not.20seeing.20the.20target&#x27;s.20target-features.html#205701967">(Aug 01 2020 at 23:07)</a>:</h4>
<p><span class="user-mention" data-user-id="133247">@bjorn3</span> even though RUSTFLAGS isn't used for building the build script itself, the <code>CARGO_CFG</code> environment variables use the flags from RUSTFLAGS.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>